<template>
  <div style="min-height: 34px">
    <el-tag
      v-for="(item, index) in data"
      style="margin-right: 5px; margin-top: 2px"
      :key="item.id"
      :hit="item.containChildrenDept"
      :closable="!disabled"
      @close="removeItem(index, item.id, item.type)"
      :type="
        item.type === 'dept'
          ? 'primary'
          : item.type === 'user'
          ? 'danger'
          : 'success'
      "
      size="default"
    >
      {{ item.name }}
    </el-tag>
  </div>
</template>

<script setup>
let emits = defineEmits(["update:data"]);

let props = defineProps({
  data: {
    type: Array,
    default: () => [],
  },
  disabled: {
    type: Boolean,
    default: false,
  },
});

const removeItem = (index, id, type) => {
  emits(
    "update:data",
    props.data.filter((res) => !(res.id === id && res.type === type))
  );
};
</script>
<style scoped></style>
